import React from "react";
import {
  HashRouter,//路有管理者
  Switch,//决定排他路由
  Route,//路由对象
  Redirect
} from "react-router-dom";
import Home from "./views/Home";
import Login from "./views/Login";


class Router extends React.Component{
  constructor(props){
    super(props);
  }

  render(){
    return(
     <div>
       <HashRouter>
         <Switch>
           <Route path="/login" component={Login}/>
           <Route path="/" render={()=>{
             var loginStatus = localStorage.getItem("token")?true:false;
             return loginStatus?<Home/>:<Redirect to="/login"/>
           }}/>
         </Switch>
       </HashRouter>
     </div>
    )
  }
}

export default Router